package com.ysd.lis.mapper;

import com.github.yulichang.base.MPJBaseMapper;
import com.ysd.common.dto.ColumnAndCommentDto;
import com.ysd.common.dto.ColumnValueDto;
import com.ysd.lis.entity.PubTaskPage;
import com.ysd.common.sqlbuilder.TransmitSqlBuilder;
import org.apache.ibatis.annotations.*;

import java.util.List;
import java.util.Map;

/**
 * <p>
 * 样品可配置项分类表 Mapper 接口
 * </p>
 *
 * @author LiuQi
 * @since 2023-11-13
 */
public interface PublicTaskMapper extends MPJBaseMapper<PubTaskPage> {

    /**
     * 模糊查询表名
     *
     * @param tableName
     * @return
     */
    @SelectProvider(type = TransmitSqlBuilder.class, method = "buildFindTableNamesSql")
    List<Map<String, String>> findTableNames(@Param("tableName") String tableName);

    /**
     * 查询表字段
     *
     * @param tableName
     * @return
     */
    @SelectProvider(type = TransmitSqlBuilder.class, method = "buildSelectColumnsByTableName")
    List<ColumnAndCommentDto> findColumnsByTableName(@Param("tableName") String tableName);

    /**
     * 新增模版实例
     *
     * @param tableName
     * @param list
     * @return
     */
    @InsertProvider(type = TransmitSqlBuilder.class, method = "buildInsertTransmitTodoSql")
    int insertTransmitTodoTable(@Param("tableName") String tableName, @Param("list") List<ColumnValueDto> list);

    /**
     * 编辑模版实例
     *
     * @param tableName
     * @param list
     * @return
     */
    @UpdateProvider(type = TransmitSqlBuilder.class, method = "buildUpdateTransmitTodoSql")
    int updateTransmitTodoTable(@Param("tableName") String tableName, @Param("list") List<ColumnValueDto> list);

    /**
     * 动态查询模板实例表
     *
     * @param tableName
     * @return
     */
    @SelectProvider(type = TransmitSqlBuilder.class, method = "buildSelectTransmitTodoSql")
    List<Map<String, Object>> getTransmitTodoData(@Param("tableName") String tableName, @Param("columnList") List<String> columnList);


    /**
     * 动态分页查询
     *
     * @param tableName
     * @param columnList
     * @return
     */
    @SelectProvider(type = TransmitSqlBuilder.class, method = "buildSelectPageTodoSql")
    List<Map<String, Object>> getPageData(@Param("tableName") String tableName, @Param("columnList") List<String> columnList, @Param("startSet") Integer startSet, @Param("endSet") Integer endSet);

    /**
     * 查询数据总数
     *
     * @param tableName
     * @return
     */
    @SelectProvider(type = TransmitSqlBuilder.class, method = "buildSelectCountSql")
    Integer getDataCount(@Param("tableName") String tableName);


    /**
     * 动态删除数据
     *
     * @param tableName
     * @param id
     * @return
     */
    @Delete("delete from ${tableName} where id = #{id}")
    boolean deleteDynamicTableData(@Param("tableName") String tableName, @Param("id") String id);

}
